<?php
session_start();
require_once('php/include/global.php');
require_once('php/include/checks.php');

ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="author" content="Wink Hosting (www.winkhosting.com)" />
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="static/css/style.css" type="text/css" />
        <script language="JavaScript">
            function popUp(URL) {
                day = new Date();
                id = day.getTime();
                eval("page" + id + " = window.open(URL, '" + id + "', 'toolbars=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=600');");
            }
        </script>

        <title>RedTie</title>
    </head>
    <body>
        <div id="page" align="center">
            <div id="content" style="width:800px">
                <div id="logo">
                    <div style="margin-top:70px" class="whitetitle">SSIG</div>
                </div>
                <div id="topheader">
                    <div align="left" class="bodytext">
                        <br />
                        <strong>SSIG</strong><br />
					Anno 2011-2011<br />
					Frequenza tempo pieno<br />
					Classe 1A
                    </div>
                    <div id="toplinks" class="smallgraytext">
                        <?php if ($user->isLogged()) { ?>     
                            Benvenuto, <?php echo $user->getUsername(); ?>
                        <?php } else { ?>
                            <a href="?p=login">Login</a> | <a href="?p=registration">Registrazione</a><br />
                            <?php include('php/pages/loginForm.page.php'); ?>
                        <?php } ?>


                    </div>
                </div>
                <div id="menu">
                    <div align="right" class="smallwhitetext" style="padding:9px;">
                        <a href="?p=home">Home</a> | <?php if (!$user->isLogged()) { ?><a href="?p=login">Login</a> | <a href="?p=registration#">Registrazione</a> | <?php } ?><?php if ($user->isLogged()) { ?><a href="?p=materie">Materie</a> | <?php } ?><?php if ($user->isLogged()) { ?> | <a href="?logout">Logout</a><?php } ?>
                    </div>
                </div>
                <!--
                <div id="submenu">
                    <div align="right" class="smallgraytext" style="padding:9px;">
                        <a href="#">Submenu 1</a> | <a href="#">Submenu 2</a> | <a href="#">Submenu 3</a> | <a href="#">Submenu 4</a> | <a href="#">Submenu 5</a> | <a href="#">Submenu 6</a>
                    </div>
                </div>
                -->
                <div id="contenttext">
                    <?php
                    if (!isset($_GET['p'])) {
                        $_GET['p'] = 'home';
                    }

                    switch ($_GET['p']) {
                        case 'home':
                            include('php/pages/home.page.php');
                            break;
                        case 'registration':
                            include('php/pages/registration.page.php');
                            break;
                        case 'login':
                            include('php/pages/login.page.php');
                            break;
                        case 'registrationSuccess':
                            include('php/pages/afterRegistration.page.php');
                            break;
                        case 'materie':
                            include('php/pages/materie.page.php');
                            break;
                        default:
                            echo '<p>';
                            include('php/pages/notFound.php');
                            echo '</p>';
                            break;
                    }
                    ?>

                    <div id="leftpanel">
                        <div align="justify" class="graypanel">
                            <span class="smalltitle">News</span><br /><br />
                            <?php $news = Attachment::getNews(); ?>
                            <?php if (isset($news) && $news != false) { ?>
                                <?php foreach ($news as $attachment_new) { ?>
                                    <span class="smallredtext"><?php echo Util::getDate($attachment_new->date) ?></span><br />
                                    <span class="bodytext"><strong><?php echo $attachment_new->name; ?></strong></span><br />
                                    <span class="bodytext"><?php echo $attachment_new->description; ?></span><br />
                                    <a href="#" class="smallgraytext">More...</a><br /><br />
                                <?php } ?>
                            <?php } ?>
                        </div>
                    </div>
                    <div id="footer" class="smallgraytext">
				Copyright &copy; 20111 :: SSIG Homework Project - created by Stefano Poncini 
                    </div>
                </div>
            </div>
    </body>
</html>